'''
*下载进度条
*
'''
import time as t


def format_memory(memory):
    return f'{memory}M' if memory <= 900 else f'{round(memory / 1024, 2)}G'


total = 560
print('\t', '<' * 30, '正在下载', '>' * 30)
for i in range(0, total + 1):
    item = round(i / total * 100)
    each = round(item / 2)
    complete = "=" * each
    incompleted = ' ' * (50 - each)
    percentage = item
    print(f'\r \t {percentage}% [{complete}>{incompleted}] {format_memory(i)}/{format_memory(total)}', end='')
    t.sleep(0.15)
print('\n\t', '<' * 30, '下载完成', '>' * 30)
